package com.caption.mq.core;

import com.caption.mq.entity.MqSubscribeDO;
import com.caption.mq.listener.AbstractMqListener;
import com.caption.mq.listener.RocketMQListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.client.RestTemplate;

public class RocketMqFactory {
    @Autowired
    RestTemplate restTemplate;

    private String address;

    /**
     * 创建消息者
     * @param mqSubscribeDO
     * @return
     */
    public AbstractMqConsumer getConsumerInstance(MqSubscribeDO mqSubscribeDO) {
        AbstractMqConsumer consumer = new RocketMqConsumer(mqSubscribeDO, address);
        return consumer;
    }

    /**
     * 创建监听者
     * @param mqSubscribeDO
     * @return
     */
    public AbstractMqListener getMqListenerInstance(MqSubscribeDO mqSubscribeDO) {
        AbstractMqListener mqListener = new RocketMQListener(mqSubscribeDO, restTemplate);
        return mqListener;
    }


}
